package cn.itcast.demo.mq.spring;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author 虎哥
 */
@Component
public class MqListener {

    @RabbitListener(queues = "topic.queue2")
    public void listenMessage(String message){
        System.out.println("接收到消息： = " + message);
    }

    @RabbitListener(queues = "simple_queue")
    public void listenMessage(Map<String,Object> message){
        System.out.println("接收到消息： = " + message);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "spring.test.queue", durable = "true"),
            exchange = @Exchange(name="spring.exchange", type = "topic"),
            key = "#"
    ))
    public void listenMessage2(String msg){
        System.out.println("msg = " + msg);
    }
}
